/* 
 * 
 * Created on 14 Oct 2011 by simonk
 * 
 * Copyright: Multicom Products Ltd. 2011 Bristol, England
 */
package gui.filetree;

import java.io.File;
import java.util.Date;

import filesystem.CFile;

import utils.DateUtil;

/**
 *
 * @author simonk
 */
public class TreeNodeInfo {
	public String name;
	public String size;
	public String lastmodified;
	public boolean isDirectory;
	
	public TreeNodeInfo(String name) {
		this.name = name;
		this.size = "0";
		this.lastmodified = DateUtil.toString(new Date());
		this.isDirectory = true;
	}
	
	public TreeNodeInfo(CFile file) {
		this.name = file.getName();
		this.size = file.getSize();
		this.lastmodified = file.getLastModified();
		this.isDirectory = file.isDirectory();
	}
	
	public TreeNodeInfo(File file) {
		this.name = file.getName();
		this.size = file.length()+"";
		this.lastmodified = DateUtil.toString(new Date(file.lastModified()));
		this.isDirectory = file.isDirectory();
	}
	
	public TreeNodeInfo(String name, String size, String lastmodified, boolean isDir) {
		this.name = isDir? name.split("&")[0] : name;
		this.size = size;
		this.lastmodified = lastmodified;
		this.isDirectory = isDir;
	}
}
